package edu.hz.enums;

import lombok.Getter;

@Getter

public enum UserTitle {

    HEARTHED_PERSON("热心人士", 0, 1000),
    CARING_PERSON("爱心人士", 1001, 5000),
    KIND_PERSON("好心人士", 5001, 10000),
    BENEVOLENT_PERSON("善心人士", 10001, 50000),
    CHARITABLE_PERSON("博爱人士", 50001, 100000),
    PHILANTHROPIST("慈善家", 100001, Integer.MAX_VALUE);

    private final String title;

    private final int minDonation;

    private final int maxDonation;

    UserTitle(String title, int minDonation, int maxDonation) {
        this.title = title;
        this.minDonation = minDonation;
        this.maxDonation = maxDonation;
    }

    public static UserTitle fromDonationAmount(int donationAmount) {
        for (UserTitle userTitle : values()) {
            if (donationAmount >= userTitle.minDonation && donationAmount <= userTitle.maxDonation) {
                return userTitle;
            }
        }
        return HEARTHED_PERSON;
    }

}
